from business.base_api import BaseApi
from common.urls import *

class Order(BaseApi):
    def order_buy(self,token,order_type):
        uploads = {
            "action": "submit",
            "goods": [
                {
                    "item_id": 2007,
                    "num": 1
                }
            ],
            "type":order_type,
            "delivery_type": 1,
            "use_integral": 0,
        }
        headers = {
            'token':token
        }
        return self.send_request(method='post',url=url_order_buy,json=uploads,headers=headers)

    def payment_prepay(self,token,order_id,pay_way,order_source,order_from = None):
        if order_source == 6:
            api_payment_prepay = 'api/payment/Prepay'
            order_from = 'order'
        uploads = {
            "from" : order_from,
            "order_id": order_id,
            "pay_way": pay_way,
            "order_source": order_source
        }
        headers = {
            'token': token
        }
        return self.send_request(method='post', url=url_payment_prepay, json=uploads, headers=headers)

if __name__ == '__main__':
    order = Order()

    order.payment_prepay()